package com.yjd.comm.fundservice.enums;

import com.yjd.comm.util.FrameUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 资金渠道
 * Created by yangchangyan on 2018/1/25.
 */
public enum FundChannelEnum {

    YMFQ("YMFQ",1,"医美分期"),
    QIAN_KANG("QIAN_KANG",2,"乾康")
    ;

    private String code;
    private int value;
    private String desc;

    public static FundChannelEnum parse(int value) {
        for (FundChannelEnum v : FundChannelEnum.values()) {
            if (v.getValue() == value) {
                return v;
            }
        }
        return null;
    }
    private static Object fundChannelLock = new Object();

    private volatile static List<Map<String,Object>> fundChannelList = new ArrayList<>();
    public static List<Map<String,Object>> getFundChannelList()throws Exception{
        if(fundChannelList.isEmpty()){
            synchronized (fundChannelLock) {
                for (FundChannelEnum v : FundChannelEnum.values()) {
                    fundChannelList.add(FrameUtil.newHashMap("key",v.getValue(),"desc",v.getDesc()));
                }
            }
        }
       return fundChannelList;
    }

    private FundChannelEnum(String code,int value,String desc){
        this.code = code;
        this.value = value;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }
}
